const App = getApp();
Page({

  data: {
    // 页面元素
    pic: '../../images/指向-bottom.png',
    topData: {},
    status: true,
    status1: true,
    scrollLeft: '',
    inspect_id:'',
    currentIndex: 0,
    pageNo: 1,
    list: [],
    tabs: [
      { key: 'today_clue', title: '当日线索' },
      { key: 'time_out', title: '即将超时' },
      { key: 'inspect', title: '预约带看' }
    ]
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onShow: function () {
    // const pages = getCurrentPages()
    // const inspect_id = pages[1].options.inspect_id
    // this.setData({
    //   inspect_id
    // })
    // let { tabs, currentIndex } = this.data
    // // this.getHomeTopData()
    // this.selectComponent('#list-com').getCustomersList(inspect_id)
  },
  onLoad: function (options) {
      let inspect_id = options.inspect_id;
      let status = options.status;
      this.setData({
        inspect_id,
        status
      })
      console.log(this.data.status)
      let { tabs, currentIndex } = this.data
      // this.getHomeTopData()
      this.selectComponent('#list-com').getCustomersList(inspect_id)
  },
  /**
   * tab切换
   */
  handleTab(e) {
    let { index, value } = e.currentTarget.dataset
    const child = this.selectComponent('#list-com')
    child.setData({
      deviceList: [],
      deviceIndex: 1
    })
    this.setData({
      currentIndex: index,
      action: value
    })
    this.selectComponent('#list-com').getCustomersList(value)
  },
  handleChange() {
    this.setData({
      status: !this.data.status
    })
    console.log(this.data.status, this.data.pic)
  },

  filterList(arr) {
    for (let index = 0; index < arr.length; index++) {
      arr[index].pic = ''
      switch (arr[index].level) {
        case 'A':
          arr[index].pic = '../../images/A.png'
          break;
        case 'B':
          arr[index].pic = '../../images/B.png'
          break;
        case 'C':
          arr[index].pic = '../../images/C.png'
          break;
        case 'D':
          arr[index].pic = '../../images/D.png'
          break;
        case 'T':
          arr[index].pic = '../../images/T.png'
          break;
        default:
          break;
      }
    }
  },
  getHomeTopData() {
    let _this = this
    App._post_form('home/getHomeTopData', {

    }, function (result) {
      console.log(result);
      _this.setData({
        topData: result.data
      })
    })
  },
  onReachBottom: function () {
    // 页面触底时执行
    this.selectComponent('#list-com').reachBottom()
  },
  /**
   * 下拉刷新
   */
  onPullDownRefresh: function () {
    // 获取首页数据
    this.selectComponent('#list-com').getCustomersList()
  },
});